window.onload = function ()
{
     var ajax = getAjax();

     ajax.open("get","/linkMenue/jsonType",true);

    /**
     * <option value='1'>山东省</option>
     */
    ajax.onreadystatechange = function ()
     {
        if (ajax.readyState == 4 && ajax.status == 200)
        {
            var result = eval("("+ajax.responseText+")");

            var appendStr1 = "<option>请选择省份</option>";
            for (var i = 0;i<result.data.length;i++)
            {
                appendStr1 += "<option value='";
                appendStr1 += result.data[i].pid;
                appendStr1 += "'>";
                appendStr1 += result.data[i].name;
                appendStr1 += "</option> ";
            }
            var provinceNode = document.getElementById('province');
            provinceNode.innerHTML = appendStr1;
        }
     }

     ajax.send();
}


function getCityByPid()
{
    var cityNode = document.getElementById('city');
    var initContent = "<option>请选择城市</option>";

    var pid = document.getElementById('province').value;
    if (!parseInt(pid))
    {
        cityNode.innerHTML = initContent;
        return;
    }
    var ajax = getAjax();

    ajax.open('get','/linkMenue/jsonCity/'+pid,true);
    ajax.onreadystatechange = function ()
    {
        if (ajax.readyState == 4 && ajax.status ==200)
        {
            var result = eval("("+ajax.responseText+")");
            if (result.success)
            {
                var cities = result.data;
                var appendStr1 = "";
                for (var i = 0;i<cities.length;i++)
                {
                    appendStr1 += "<option value='";
                    appendStr1 += result.data[i].pid;
                    appendStr1 += "'>";
                    appendStr1 += result.data[i].name;
                    appendStr1 += "</option> ";
                }
                cityNode.innerHTML = appendStr1;
            }else {
                cityNode.innerHTML = initContent;
            }
        }
    }

    ajax.send();
}

function getAjax()
{
    var ajax = null;
    try
    {
        ajax = new XMLHttpRequest();
    }catch (e)
    {
        ajax = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return ajax;
}